import java.util.Objects;
import java.util.Scanner;

public class Student {
	private int id;
	private String name;
	private double score;
	
	
	public Student() {
	}


	public Student(int id, String name) {
		this.id = id;
		this.name = name;
	}


	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	@Override
	public int hashCode() {
		return Objects.hash(id, name);
	}

	
	//a.equals(b)

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Student other = (Student) obj;
		return id == other.id && Objects.equals(name, other.name);
	}


	@Override
	public String toString() {
		return "Student [id=" + id + ", name=" + name + "]";
	}
	
	
	public static void main(String[] args) {
		//创建对象数组
		Student[] students = new Student[3];
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < students.length; i++) {
			//System.out.println("请输入学生ID");
			int id = i + 1;//sc.nextInt();
			System.out.println("请输入学生姓名");
			String name = "张三" + i;//sc.next();
			students[i] = new Student(id,name); 
		}
		
		Student s = students[0];
		for (Student student : students) {
			System.out.println(student);
		}
		
		//你需要去查询name是张三0；
		Student stu = getStudent(students,"张三0");
		System.out.println(stu);
	}


	private static Student getStudent(Student[] students, String name) {
		if (null == name) {
			return null;
		}
		
		for (Student student : students) {
			if (name.equals(student.getName())) {
				return student;
			}
		}
		
		return null;
	}
	
	
	
	//定义学生类  id name score
	//定义一个长度为5的对象数组
	//通过控制台输入属性值存在该类的对象中，并且把对象存储到数组中
	//打印所有的对象内容
	//查询某一个对象
	//以成绩进行降序排列
	
	
	

}
